<?php
/*****************
* iSkysoft 模板接口类
*创建日期:2012-4-24
*作者：tjx
******************/

include(dirname(__FILE__).'/../public/public_support.php');
class  IskysoftSupport  extends PublicSupport {
	
	function __construct($arr = NULL) {
		
	}
	
	/**
	* 得到推荐分类组合
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getRecommendCategory($get = array()) {
		
		$str = '';
		//得到公共函数返回的 sql
		$sql = $this->recommendCategory($get);
		$result = $GLOBALS['db']->query($sql);

		while($rs = $GLOBALS['db']->fetch_array($result)) {
			$str .= '<li>'.$rs['type_name'].'</li>';
		}
		unset($rs);
		return $str;
	}
	
	/**
	* 推荐Order文章
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getRecommendOrderArticle($get = array()) {
		
		$str = '';
		$get['limit'] = 5;
		//得到公共函数返回的 $arr
		$arr = $this->recommendOrderArticle($get);
		$webInfo = $arr['webInfo'];
		
		$result = $GLOBALS['db']->query($arr['sql']);
		
		$i = 1;
		while ($rs = $GLOBALS['db']->fetch_array($result)) {
			
			if ($rs['type_id'] == 6){
				$sql = "SELECT url 
						FROM Table_{$webInfo['faq_info']['table']} 
						WHERE Field_{$webInfo['faq_info']['temKey']} = '{$rs['id']}'" ;
				
			} else {
				$sql = "SELECT url 
						FROM Table_{$webInfo['order_info']['table']} 
						WHERE Field_{$webInfo['order_info']['temKey']} = '{$rs['id']}' " ;
				
			}
			
			$url = url_new_replace($GLOBALS['db']->getOne($sql), $webInfo['url_type'], $webInfo['web_domain']);
			
			if (strlen($rs['title']) > 60) {
				$rs['sub_title'] = substr($rs['sub_title'], 0, 60).'...';
			} else {
				$rs['sub_title'] = $rs['sub_title'];
			}
					
			$class = ' class="question" ';
			if ($i % 2 == 0) {
				$class = ' class="question even" ';
			}
			$str .= '<p class='.$class.'>▪ <a href="'.$url.'">'.$rs['sub_title'].'</a></p>	';
		}
		
		unset($rs);
		return $str;
	}
	
	/**
	* 得到分类相关FAQ信息
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getCategoryRelatedFaq($get = array() ) {
		
		$str = '';
		//得到公共函数返回的 $arr
		$arr = $this->categoryRelatedFaq($get);
		$webInfo = $arr['webInfo'];
		$cate_row = $arr['cate_row'];
		
		foreach ($cate_row AS $value) {
			
			if ($value == 6 ){
				$sql = "SELECT new.title,type.type_name,tem.url 
						FROM faq_operation_types AS o_type 
						LEFT JOIN faq_info_new new ON o_type.id = new.id 
						LEFT JOIN Table_{$webInfo['faq_info']['table']} tem ON tem.Field_{$webInfo['faq_info']['temKey']} = new.id 
						LEFT JOIN faq_type type ON new.type_id = type.type_id	 
						WHERE new.type_id = '{$value}' AND o_type.web_type = '{$webInfo['web_fage']}' AND new.web_type = '{$webInfo['web_fage']}' AND o_type.is_recommend_index = 1 LIMIT 10 ";
			
			} else {
				$sql = "SELECT new.title,type.type_name,tem.url 
						FROM faq_operation_types AS o_type 
						LEFT JOIN faq_info_new new ON o_type.id = new.id 
						LEFT JOIN Table_{$webInfo['order_info']['table']} tem ON tem.Field_{$webInfo['order_info']['temKey']} = new.id 
						LEFT JOIN faq_type type ON new.type_id = type.type_id 
						WHERE new.type_id = '{$value}' AND o_type.web_type = '{$webInfo['web_fage']}' AND new.web_type = '{$webInfo['web_fage']}' AND o_type.is_recommend_index = 1 LIMIT 10 ";
			
			
			}
			$result = $GLOBALS['db']->query($sql);
			$i = 0;
			while ($rs = $GLOBALS['db']->fetch_array($result)) { 
				
				if (strlen($rs['title']) > 60) {
					$rs['s_title'] = substr($rs['title'], 0, 60).'...';
				} else {
					$rs['s_title'] = $rs['title'];
				}
				
				$url = url_new_replace($rs['url'], $webInfo['url_type'], $webInfo['web_domain']);
				if ($i == 0) {
					$str .= '<div class="tab_cont"><dl><dt>'.$rs['type_name'].'</dt>';
				}
				
				if ($i % 2 == 0) {
					$str .= '<dd class="lbg"><a href="'.$url.'" title="'.$rs['title'].'" >'.$rs['s_title'].'</a></dd>';
				} else {
					$str .= '<dd><a href="'.$url.'" title="'.$rs['title'].'" >'.$rs['s_title'].'</a></dd>';
				}
				$i = $i + 1;
			}
			
			if ($value == 6) {
				$url = 'product-support/how-tos/';
			} else {
				$sql = "SELECT Table_{$webInfo['order_category']['table']}.url 
						FROM Table_{$webInfo['order_category']['table']},faq_type 
						WHERE faq_type.type_name = Table_{$webInfo['order_category']['table']}.Field_{$webInfo['order_category']['categoryName']} AND faq_type.type_id = '{$value}'";
		
				$url = url_new_replace($GLOBALS['db']->getOne($sql), $webInfo['url_type'], $webInfo['web_domain']);
			}
			
			if (!empty($i)){
				$str .= '</dl><p class="more"><a href="'.$url.'">More>></a></p></div>';
			}
		
		}
		
		unset($rs);
		return $str;
	}
	
	/**
	* 得到推荐产品组合
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getRecommendProducts($get = array() ) {
		
		$str = '';		
		if ($get['TID'] == 148) {//表示为Table_148表  
			$get['limit'] = 5; 
		} elseif($get['TID'] == 152) {//表示为Table_148 表 
			$get['limit'] = 8;
		}
		
		$arr = $this->recommendProducts($get);
		$webInfo = $arr['webInfo'];
		
		$result = $GLOBALS['db']->query($arr['sql']);
		while ($rs = $GLOBALS['db']->fetch_array($result)) {
			
			$url = url_new_replace($rs['url'], $webInfo['url_type'], $webInfo['web_domain']);
			$str .= '<div class="item"><a href="'.$url.'"><img src="'.$rs['product_box_middle'].'"  height="105" />
					<div class="mt10">'.$rs['product_name'].'</div></a></div>';
		}
	
		unset($rs);
		return $str;
		
	}
	
	/**
	* 得到Order分类列表
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function  getOrderCategoryList($get = array() ){
		
		$str =  '';
		$arr = $this->orderCategoryList($get);
		$webInfo = $arr['webInfo'];

		$result = $GLOBALS['db']->query($arr['sql']);
		while($rs = $GLOBALS['db']->fetch_array($result)) {
			
			$url = url_new_replace($rs['url'], $webInfo['url_type'], $webInfo['web_domain']);
			$str .= '<li ><a href="'.$url.'">▪'.$rs['type_name'].'</a></li>';
		}
		
		unset($rs);
		return $str;
		
	}
	
	/**
	* 得到具体分类相关FAQ
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function  getDefiniteCategoryRelatedFaq($get = array() ) {
		
		$str = '';
		$type_name = trim($get["FAQ分类名称"]); //得到faq分类
		$arr = $this->definiteCategoryRelatedFaq($get);
		$webInfo = $arr['webInfo'];
		
		$i = 0;
		while ($rs = $GLOBALS['db']->fetch_array($result)) {
			
			$url = url_new_replace($rs['url'], $webInfo['url_type'], $webInfo['web_domain']);
			if ($i % 2 == 0) {
				$str .= '<li class="bg"><a href="'.$url.'">'.$rs['title'].'</a></li>' ;
			} else {
				$str .= '<li><a href="'.$url.'">'.$rs['title'].'</a></li>' ;
			}
			$i = $i + 1;
		}
		
		if ($i != 0  ) {
			$str = '<div class="title2"><h1>'.$type_name.'</h1> </div><ul class="n_list1">'.$str.'</ul>';
		}
		
		unset($rs);
		return  $str;
		
	}
	
	/**
	* 得到Order_Support相关分类
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function  getRelatedCategory($get = array() ) {
		
		$str = '';
		$arr = $this->relatedCategory($get);
		$webInfo = $arr['webInfo'];
		
		$result = $GLOBALS['db']->query($webInfo['sql']);
		$i = 0;
		while ($rs = $GLOBALS['db']->fetch_array($result)) {
			
			$url = url_new_replace($rs['url'], $webInfo['url_type'], $webInfo['web_domain']);
			if ($i % 2 == 0) {
				$str .= '<div class="item bg">' ;
			} else {
				$str .= '<div class="item">' ;
			}
			
			$str .= '<img src="http://'.$webInfo['web_domain'].'/style/style_img/Topics.png" width="45" height="42" class="fl" />
					<dl class="text"><dt><a href="'.$url.'">'.$rs['Field_20794'].'</a></dt>
					<dd>'.$rs['Field_20797'].'</dd></dl></div>';
			$i = $i + 1;
		}
		
		unset($rs);
		return  $str;
		
	}
	
	/**
	* 得到Order_Support具体Order分类列表
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function  getDefiniteOrderCategoryList($get = array() ){
		
		$str = '';
		$type_name = trim($get["FAQ分类名称"]); //得到faq分类
		
		$arr = $this->definiteOrderCategoryList($get);
		$webInfo = $arr['webInfo'];
		
		$result = $GLOBALS['db']->query($arr['sql']);
		while ($rs = $GLOBALS['db']->fetch_array($result)) {
			
			 $a_select_css = '';
			if ($type_name == trim($rs['type_name'])) {
				$a_select_css = 'class="curr"';
				
			}
			$url = url_new_replace($rs['url'], $webInfo['url_type'], $webInfo['web_domain']);
			$str .= '<li ><a '.$a_select_css.' href="'.$url.'">▪  '.$rs['type_name'].'</a></li>';
		}
		unset($rs);
		return $str;
		
	}
	
	/**
	* 得到Order文章内容
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getArticleContent($get = array() ) {
		
		$a_id = (int) $get["文章ID"];
		$webInfo =  $this->getWebInfo($get['web_type']);//根据网站得到相应的信息
		$a_type = empty($get["文章类型"]) ? '' : trim($get["文章类型"]);
		
		if ($a_type == '在线帮助文章') {
			
			$sql_c =  "SELECT content 
						FROM online_help 
						WHERE id = {$a_id} AND web_type = '{$webInfo['web_fage']}' " ;
			$contents = $GLOBALS['db']->getOne($sql_c);
			
			/**
			 * * 以下是对iskysoft的在线帮助的内容中含有faq老链接替换成改版后的链接
 			* */
			
			preg_match_all ("/\<a(.*?)href=\"(.*?)\"(.*?)\>/", $contents, $matches);

			for ($i = 0; $i< count($matches[0]); $i++)  {
				
				if (substr_count($matches[2][$i], 'submod=faq') > 0) {
					$urlArr = explode('id=', $matches[2][$i]);
					$faqId = (INT) $urlArr[1];
					
					if (!empty($faqId)) {
						
						$sql = "SELECT url 
								FROM Table_{$webInfo['order_info']['table']} 
								WHERE Field_{$webInfo['order_info']['temKey']} = {$faqId} ";
						
						$url = $GLOBALS['db']->getOne($sql);
						
						if (empty($url)) {
							$sql = "SELECT url 
									FROM Table_{$webInfo['faq_info']['table']} 
									WHERE Field_{$webInfo['faq_info']['temKey']} = {$faqId} ";
							
							$url = $GLOBALS['db']->getOne($sql);
						}
				
					}
				}
				if (!empty($url)) {
					$contents = str_replace($matches[2][$i], url_new_replace($url, $webInfo['url_type'], $webInfo['web_domain']), $contents);
				}
				
			}
			//替换图片绝对链接为 i.iskysoft.com 域名的 绝对地址
			return support_replace_img($contents, 'i.iskysoft.com');
		}else {
			$sql_c =  "SELECT contents 
						FROM faq_info_new 
						WHERE id = {$a_id} AND web_type = '{$webInfo['web_fage']}'";
			
		}
		
		$contents = $GLOBALS['db']->getOne($sql_c);
		return support_replace_img($contents, 'i.iskysoft.com');
	}
	
	/**
	* 得到Order_Support文章   Order文章分类列表
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function  getArticleOrderCategoryList($get = array() ){
		
		$str =  '';
		$arr = $this->articleOrderCategoryList($get);
		$webInfo = $arr['webInfo'];
		
		$rows = $GLOBALS['db']->getAll($arr['sql']);
		foreach ($rows AS $key => $value) {
			
			 $a_select_css = '';
			 if($webInfo['type_id'] == $value['type_id'] ) {
				$a_select_css = 'class="curr"';
			 }
			$url = url_new_replace($value['url'], $webInfo['url_type'], $webInfo['web_domain']);
			$str .= '<li ><a '.$a_select_css.' href="'.$url.'">▪ '.$value['type_name'].'</a></li>';
		}
		unset($rows);
		return $str;
		
	}
	
	/**
	* 得到Order_Support文章   对应其他分类Order文章
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getOrderOtherCategoryArticle($get = array() ){
		
		$str =  '';
		$arr = $this->orderOtherCategoryArticle($get);
		$webInfo = $arr['webInfo'];
		
		$result = $GLOBALS['db']->query($arr['sql']);
		while ($rs = $GLOBALS['db']->fetch_array($result)){
			
			$rs['sub_title'] = strlen($rs['title']) > 100 ? substr($rs['title'], 0, 100).'...' : $rs['title'];
			$url = url_new_replace($rs['url'], $webInfo['url_type'], $webInfo['web_domain']);
			$str .= '<li><a href="'.$url.'" title="'.$rs['title'].'">'.$rs['sub_title'].'</a></li>';  
		}
		unset($rs);
		return $str;	
		
	}
	
	/**
	* 得到   所有所有一级分类
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getAllOneCategory($get = array() ) {
		
		$str = '';
		$arr = $this->allOneCategory($get);
		$webInfo = $arr['webInfo'];
	
		$result = $GLOBALS['db']->query($arr['sql']);
		while ($rs = $GLOBALS['db']->fetch_array($result)) {
			
			$url = url_new_replace($rs['url'], $webInfo['url_type'], $webInfo['web_domain']);
		
			$str.='<li><a href="'.$url.'">'.$rs['cat_title'].'</a></li>' ;
		}
		
		unset($rs);
		return $str;	
	
	}
	
	/**
	* 得到   所有所有一级分类
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getDefiniteAllOneCategory($get = array() ) {
		
		$str = '';
		$cat_id =  trim($get['产品分类ID']) ;
		$arr = $this->definiteAllOneCategory($get);
		$webInfo = $arr['webInfo'];
		
		$result = $GLOBALS['db']->query($arr['sql']);
		while ($rs = $GLOBALS['db']->fetch_array($result)) {
			
			$url = url_new_replace($rs['url'], $webInfo['url_type'], $webInfo['web_domain']);
			$a_select_css = '';
			if ($cat_id == $rs['cat_id'] ) {
				$a_select_css = 'class="curr"';
			}
			
			$str .= '<li ><a '.$a_select_css.' href="'.$url.'">▪  '.$rs['cat_title'].'</a></li>' ;
		}
		unset($rs);
		return $str;	
	
	}
	
	/**
	* 得到   二级分类以及相关产品
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getTwoCategoryRelatedProducts($get = array() ){
		
		$str = '';
		$cat_id = (int) $get['产品分类ID'];
		$arr = $this->twoCategoryRelatedProducts($get);
		$webInfo = $arr['webInfo'];
		
		$res1 = $GLOBALS['db']->query($arr['sql']);
		while ($row1 = $GLOBALS['db']->fetch_array($res1)) {
			
			$sql = "SELECT p.product_name,p.product_box_middle,tab.url 
					FROM won_product won_p 
					LEFT JOIN product p ON p.product_id = won_p.won_product_id 
					LEFT JOIN category cat ON cat.cat_id = won_p.cat_id 
					LEFT JOIN Table_{$webInfo['products_info']['table']} tab ON tab.Field_{$webInfo['products_info']['pId']} = won_p.id 
					WHERE FIND_IN_SET('{$row1['cat_id']}', cat.parent_path) AND cat.cat_type = 2 AND cat.cat_web = '{$webInfo['web_fage']}' 
						  AND cat.is_delete =0 AND won_p.won_product_delete = 0 AND cat.cat_series = 3 {$webInfo['products_category']['whereRelatedProducts']} 
					ORDER BY won_p.is_emphasis DESC ";
			
			$res2 = $GLOBALS['db']->query($sql);

			$str .= '<div class="product-list"><h2>'.$row1['cat_title'].'</h2>';
			while ($row2 = $GLOBALS['db']->fetch_array($res2)) {
				 $url = url_new_replace($row2['url'], $webInfo['url_type'], $webInfo['web_domain']);
				 
				 $str .= '<div class="item"><a href="'.$url.'"><img src="'.$row2['product_box_middle'].'" height="100px;" width="100px;" />
				 <div class="mt10">'.$row2['product_name'].'</div></a></div>';
			}
			$str .='</div>';

		}
		
		$sql = "SELECT tab.url,tab.Field_{$webInfo['products_category']['categoryName']} 
				FROM Table_{$webInfo['products_category']['table']} tab 
				WHERE tab.Field_{$webInfo['products_category']['temKey']} != {$cat_id} LIMIT 1 ";
		$row1 = $GLOBALS['db']->getOneRs($sql);
		
		$url = url_new_replace($row1['url'], $webInfo['url_type'], $webInfo['web_domain']);
		
		$str .= '<a href="'.$url.'" class="fr">Go to '.$row1['Field_'.$webInfo['products_category']['categoryName']].' >></a>';

		unset($row2,$row1);
		return $str;
	}
	
	/**
	* Order分类以及文章列表
	* @param   array      		 $get       字段数组
	* @return  string
	* @return  array
	*/
	function getOrderCategoryArticleList($get = array() ) {
		
		$str ='';
		$arr = $this->orderCategoryArticleList($get);
		$webInfo = $arr['webInfo'];	

		$rows = $GLOBALS['db']->getAll($arr['sql']);
		foreach ($rows AS $values) {
			
			$str.= '<h2> '.$values['type_name'].'</h2><div class="toggle-item">';
			$sql = "SELECT * 
					FROM ( (
					SELECT new.id , new.title,tab.url 
					FROM faq_info_new new 
					LEFT JOIN Table_{$webInfo['order_info']['table']} tab ON tab.Field_{$webInfo['order_info']['temKey']} = new.id 
					WHERE new.id IN (
					    SELECT id 
					    FROM faq_operation_types 
					    WHERE web_type = '{$webInfo['web_fage']}' AND is_important = 1 ) AND new.type_id = '{$values['type_id']}' AND new.web_type = '{$webInfo['web_fage']}' ) 
					UNION ALL (
					SELECT new.id , new.title,tab.url 
					FROM faq_info_new new 
					LEFT JOIN Table_{$webInfo['order_info']['table']} tab ON tab.Field_{$webInfo['order_info']['temKey']} = new.id 
					WHERE new.id NOT IN (
					    SELECT id 
					    FROM faq_operation_types 
					    WHERE web_type = '{$webInfo['web_fage']}' AND is_important = 1 ) AND new.type_id = '{$values['type_id']}' AND new.web_type = '{$webInfo['web_fage']}' 
					ORDER BY new.id ) ) newFaq LIMIT 4 ";
			
			$result = $GLOBALS['db']->query($sql);
			
			$sql = "SELECT url 
					FROM Table_{$webInfo['order_category']['table']} 
					WHERE Field_{$webInfo['order_category']['categoryName']} = '{$values['type_name']}' ";
			
			$url_type = url_new_replace($GLOBALS['db']->getOne($sql), $webInfo['url_type'], $webInfo['web_domain']);
			$nums = 0;
			
			while ($rs = $GLOBALS['db']->fetch_array($result)) {
				
				
				$url = $url_type.'#'.$rs['id'];
				$str .= '<p class="question">▪ <a href="'.$url.'">'.$before_type_name_str.$rs['title'].'</a></p>';
				$nums ++;
			}
			if ($nums == 4) {
				$str .= ' <div class="mt10 ml20"><a href="'.$url_type.'" >More about '.$values['type_name'].' >></a></div><br /><br />'; 
			}
			$str .= '</div>';
		}
		unset($rs, $rows);
		return $str;
	}
	
	/**
	*得到四条快捷记录与视频代码
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function  getProductQuickRecord($get = array() ) {
		
		$str = '';
		$product_name = empty($get["ws产品名称"]) ? trim($get["产品名称"]) : trim($get["ws产品名称"]);
		$arr = $this->productQuickRecord($get);
		$webInfo = $arr['webInfo'];	
	
		if (!empty($arr['help_url'])) {
			$url = url_new_replace($arr['help_url'], $webInfo['url_type'], $webInfo['web_domain']);
			$str .= '<li><img src="../images/overview_03.png"  /><a href="'.$url.'" >'.$product_name.' getting started</a></li>';
		
		}

		$row = $GLOBALS['db']->getAll($arr['sql_v']);
		if (!empty($row[0])) {
			$str .='<li><img src="../images/overview_06.png"  /><a href="'.$row[0]['download_url'].'" >Download '.
					$product_name.' V'.$row[0]['version_name'].'</a></li>';
		}
		
		if (!empty($arr['p_url'])) {
			$p_url = url_new_replace($arr['p_url'], $webInfo['url_name'], $webInfo['web_domain']);
			$str.='<li><img src="../images/overview_08.png"  /><a href="'.$p_url.'" >View Detail of '.$product_name.'</a></li>';
		}
		
		unset($row);
		return  $str;
	}
	
	/**
	* 得到产品相关FAQ文章
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getProductRelatedFaqArticle($get = array() ) {
		
		$str = '';
		$arr = $this->productRelatedFaqArticle($get);
		$webInfo = $arr['webInfo'];	
		
		$res = $GLOBALS['db']->query($arr['sql']);
	
		$nums = 0;
		while ($values = $GLOBALS['db']->fetch_array($res)) {
			
			if (!empty($values['title'])) {
				$url = url_new_replace($values['url'], $webInfo['url_type'], $webInfo['web_domain']);
	
				$title = $values['title'];
				if (strlen($title) > 80) {
					$title = substr($title, 0, 80).'...' ;
				}
				$str .= '<li ><a href="'.$arr['moreUrl'].'#'.$values['id'].'" title ="'.htmlspecialchars($values['title']).'" >▪ '.
						$title.'</a></li>';	
				$nums++;
			}
		
		}
		if ($nums == 0) {
			return '';
		}
		
		$str_more = '';
		if ($nums == 10) {
			$str_more = '<a href="'.$arr['moreUrl'].'" class="ml20">More >></a>';
		
		}
		$str = '<ul class="ml20">'.$str.'</ul>'.$str_more;
		unset($row);
		return $str;
		
	}
	
	/**
	* 得到产品对应其他文章
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getProductRelativeOtherArticle($get = array() ) {
		
		$str = '';
		$arr = $this->productRelativeOtherArticle($get);
		$webInfo = $arr['webInfo'];	
		
		$res = $GLOBALS['db']->query($arr['sql']);
		$i = 0;
		$find_str = 0;
		while ($row = $GLOBALS['db']->fetch_array($res)) {
			
			if ($i >= 3) {
				break; 
			}
			$sql = "SELECT faq.title,tem.url,faq.id 
					FROM Table_{$webInfo['faq_info']['table']} AS tem 
					LEFT JOIN faq_info_new AS faq ON faq.id = tem.Field_{$webInfo['faq_info']['temKey']} 
					WHERE !FIND_IN_SET(faq.id,'{$find_str}') AND FIND_IN_SET('{$row['version_id']}',faq.version_id) AND faq.web_type = '{$webInfo['web_fage']}' LIMIT 3 " ;
								
			$result = $GLOBALS['db']->query($sql);
			
			while ($rs = $GLOBALS['db']->fetch_array($result)) {
				if ($i >= 3) {
					break; 
				}
				$url = url_new_replace($rs['url'], $webInfo['url_type'], $webInfo['web_domain']);
				$str .= '<li><a href="'.$url.'" >▪  '.$rs['title'].'</a></li>';  
				$find_str = $find_str.','.$rs['id'];
				$i++;
			}
		}
		
		if ($i ==  0) {
			return '';
		}
		$str = ' <div class="otherArea related-FAQ"><h4>Related FAQ</h4>
				<ul>'.$str.'</ul></div>';
		unset($row, $rs);
		return $str;
	}
	
	/**
	* 得到FAQ对应其他文章
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getFaqRelativeOtherArticle($get = array() ) {
		
		$str = '';
		$arr = $this->faqRelativeOtherArticle($get);
		$webInfo = $arr['webInfo'];	
		
		$res = $GLOBALS['db']->query($arr['sql']);
		$find_str = trim($get["文章ID"]);
		$i = 0;
		
		while ($row = $GLOBALS['db']->fetch_array($res)) {
			if ($i >= 3) {
				break; 
			}
			
			$sql = "SELECT * 
					FROM ( ( 
					SELECT faq.title,tab.url,faq.id 
					FROM faq_info_new AS faq 
					LEFT JOIN Table_{$webInfo['faq_info']['table']} AS tab ON tab.Field_{$webInfo['faq_info']['temKey']} = faq.id 
					WHERE FIND_IN_SET('{$row['version_id']}',faq.version_id) AND faq.type_id = 6 AND !FIND_IN_SET(faq.id,'{$find_str}') AND faq.id IN (
					    SELECT id 
					    FROM faq_operation_types 
					    WHERE web_type = '{$webInfo['web_fage']}' AND is_important = 1 ) AND faq.web_type = '{$webInfo['web_fage']}' ) 
					UNION ALL ( 
					SELECT faq.title,tab.url,faq.id 
					FROM faq_info_new AS faq 
					LEFT JOIN Table_{$webInfo['faq_info']['table']} AS tab ON tab.Field_{$webInfo['faq_info']['temKey']} = faq.id 
					WHERE FIND_IN_SET('{$row['version_id']}',faq.version_id) AND faq.type_id = 6 AND !FIND_IN_SET(faq.id,'{$find_str}') AND faq.id NOT IN (
					    SELECT id 
					    FROM faq_operation_types 
					    WHERE web_type = '{$webInfo['web_fage']}' AND is_important = 1 ) AND faq.web_type = '{$webInfo['web_fage']}' ) ) faq_new LIMIT 3 ";		
			$result = $GLOBALS['db']->query($sql);
			
			while ($rs = $GLOBALS['db']->fetch_array($result)) {
				if ($i >= 3) {
					break; 
				}
				if (!empty($rs['url'])) {
					$url = url_new_replace($rs['url'], $webInfo['url_type'], $webInfo['web_domain']);
					
					$rs['sub_title'] = strlen($rs['title']) > 100 ? substr($rs['title'], 0, 100).'...' : $rs['title'];
					
					$str .= '<li><a href="'.$url.'" title="'.$rs['title'].'"  >'.$rs['sub_title'].'</a></li>';  
					$find_str = $find_str.','.$rs['id'];
					$i++;
				}
			}
		}
		
		if($i ==  0) {
			return '';
		}
		
		$str = ' <div class="otherArea related-FAQ"><h4>Related FAQ</h4>
				<ul>'.$str.'</ul></div>';
		
		unset($row, $rs);
		return $str;
	}
	
	/**
	* 得到FAQ所属产品
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getFaqBelongToProduct($get = array() ) {
		
		$str = '';
		$arr = $this->faqBelongToProduct($get);
		$webInfo = $arr['webInfo'];	
		
		$res = $GLOBALS['db']->query($arr['sql']);
		while ($row = $GLOBALS['db']->fetch_array($res)) {
			
			$row['product_name'] = trim(str_replace($row['product_brand'], '', $row['product_name']));
			$url = url_new_replace($row['url'], $webInfo['url_type'], $webInfo['web_domain']);
			$str .= '<li><a href="'.$url.'"> '.$row['product_name'].'</a></li>';
		}
		
		if (!empty($str)) {
			$str = '<div class="sideNav"><h2>Product Support </h2>
					<p style="margin-left:5px;">FAQ for the following product:</p><ul class="mtb10"> '.$str.'</ul><div class="con">
					</div> </div>';
		}
		unset($row);
		return $str;
	}
	
	/**
	* 得到whatisnew_content内容
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getProductWhatisnewContent($get = array() ) {
		
		$str = '';
		$product_name = empty($get["ws产品名称"]) ? trim($get["产品名称"]) : trim($get["ws产品名称"]);
		$arr = $this->productWhatisnewContent($get);
		$webInfo = $arr['webInfo'];	
		
		$rows = $GLOBALS['db']->getAll($arr['sql']);
		foreach ($rows AS $key => $values) {
			
			$whatisnew_content= str_replace("\n", " <br>", $values['whatisnew_content']);
			
			$str .= '<div class="toggle-item">
					<strong class="question">'.$product_name.$values['version_name'].' is Released. '.'('.$values['publish_date'].')</strong>
					<div class="answer">'.$whatisnew_content.'</div>
					</div>';
		}
		unset($rows);
		return $str;
	}
	
	/**
	* 得到history对应其他文章
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getHistoryRelativeOtherArticle($get = array() ) {
		
		$str = '';
		$arr = $this->historyRelativeOtherArticle($get);
		$webInfo = $arr['webInfo'];	
		
		$result = $GLOBALS['db']->query($arr['sql']);
		while ($rs = $GLOBALS['db']->fetch_array($result)) {
			
		  $url = url_new_replace($rs['url'], $webInfo['url_type'], $webInfo['web_domain']);
		  $str .= '<li><a href="'.$url.'" >'.$rs['title'].'</a></li>';  
		}
		unset($rs);
		return $str;
	}
	
	/**
	* 得到地图Order分类列表
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getMapOrderCategoryList($get = array() )  {
		
		$str = '';
		$arr = $this->mapOrderCategoryList($get);
		$webInfo = $arr['webInfo'];	
		
		$result = $GLOBALS['db']->query($arr['sql']);
		while ($rs = $GLOBALS['db']->fetch_array($result)) {
			
			$url = url_new_replace($rs['url'], $webInfo['url_type'], $webInfo['web_domain']);
			$str .= '<dd><a href="'.$url.'">'.$rs['type_name'].'</a></dd>';
		}
		unset($rs);
		return $str;
	}
	
	/**
	* 得到地图产品所有一级分类
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getMapAllProductCategory($get = array() ) {
		 
		$str =  '';
		$arr = $this->mapAllProductCategory($get);
		$webInfo = $arr['webInfo'];	
		
		$result = $GLOBALS['db']->query($arr['sql']);
		while($rs = $GLOBALS['db']->fetch_array($result)) {
			
			$select_css = '';
			$url = url_new_replace($rs['url'], $webInfo['url_type'], $webInfo['web_domain']);
			
			$str .= '<dd ><a href="'.$url.'">'.$rs['cat_title'].'</a></dd>' ;
		}
		return $str;	
	}
	
	/**
	* 得到是否有在线帮助
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getProductOnhelpHref($get = array() ) {
		
		$str =  '';
		$arr = $this->productOnhelpHref($get);
		//表示为Table_158表
		$a_select_css = '';
		if ($get['TID'] == 158 ) {
			$a_select_css = 'class="curr"';
		}
		
		if (!empty($arr['url'])) {
			 return '<li ><a '.$a_select_css.' href="'.$arr['url'].'">▪  '.'Getting Started</a></li>';
		} else {
			return '';
		}
	}
	
	/**
	* 得到是否有Troubleshooting
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getProductHowtosHref($get = array() ) {
		
		$arr = $this->productHowtosHref($get);
		//表示为Table_157表
		$a_select_css = '';
		if ($get['TID'] == 157 ) {
			$a_select_css = 'class="curr"';
		}
		
		if (!empty($arr['url'])) {
			 return '<li  ><a '.$a_select_css.' href="'.$arr['url'].'">▪  '.'How-to & Troubleshooting</a></li>';
		} else {
			return '';
		}
	
		
	}
	
	/**
	* 得到具体Order分类相关faq列表和分页信息  生成分页
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getDefiniteOrderCategoryFaqCreatePage($get = array() ) {
		
		$arr = $this->definiteOrderCategoryFaqCreatePage($get);
		$webInfo = $arr['webInfo'];
		$total = $arr['total'];
		$max_page = $arr['max_page'];
		$dirurl = $arr['dirurl'];
		$dir = $arr['dir'];
		$template_str = $arr['template_str'];
		$all = $arr['all'];
		
		for ($i = 1; $i <= $max_page; $i++) {
			
			$list = '';
			$temp = $template_str;
			$page_start = ($i-1) * 10 + 1;
			$page_end =($i - 1) * 10 + 10;
			
			if ($page_end >= $total) {
				$page_end = $total;
			}
			
			$chang_sum = 0;
			$k = 0;
			for ($j = ($i - 1)* 10; $j <= $i * 10 - 1; $j++) {
				
				if ($j >= $total) {
					break;   
				}
				$url = url_new_replace($all[$j]['url'], $webInfo['url_type'], $webInfo['web_domain']);
			
				$list.='<div class="toggle-item" id="'.$all[$j]['id'].'">';
				$chang_sum = $chang_sum + 1;
				$list.='<a  class="question" href="#'.$all[$j]['id'].'"><strong id="title_'.$all[$j]['id'].'">'.$all[$j]['title'].'</strong></a><div class="answer"><p>
				'.support_replace_img($all[$j]['contents'], 'i.iskysoft.com').'</p>
				<div class="mtb10"><strong>Is this information helpful?</strong>
				<label><input name="helpful_'.$all[$j]['id'].'" type="radio"  onclick="insert_comment('.$all[$j]['id'].',1,1)"/> Yes</label> 
				<label><input name="helpful_'.$all[$j]['id'].'" type="radio"  onclick="insert_comment('.$all[$j]['id'].',0,1)"/> No</label>
				</div></div></div>';
				$k = $k +1;
			}
			if ($total > 10) {
				//分页
				$page = '<div id="page">';
				
				if ( $i  > 1 ) {
					if ($i -1 == 1) {
						$page .= '<a href="'.'../'.$dirurl.'/" > Prev Page</a>';
					} else {
						$page .= '<a href="'.'../'.$dirurl.'/'.($i - 1).'.html" >Prev Page</a>';
					}
				} else {
					$page .= '<a >< prev page</a>';
				}
				$start = $i - 4;
				$end = $i + 4;
				
				if ($start < 1) {
					$start = 1; $end = 6;
				}
				
				if ($end > $max_page) {
					$end = $max_page; $start = $max_page - 5;
				}
				
				if ($start < 1){
					$start = 1;
				}
				
				if ($start != 1) {
					$output .= '';
				}
				
				for ($start; $start <= $end; $start++) {
					
					if ($i == $start) {
						$page .= '<a class="now_page" >'.$start.'</a>';
					} else {
						if($start == 1){
							$page .= '<a href="'.'../'.$dirurl.'/">'.$start.'</a>';
						} else {
							$page .= '<a href="'.'../'.$dirurl.'/'.$start.'.html">'.$start.'</a>';
						}
					}
				}
				
				if ($end != $max_page) {
					$output .= '';
				}
				
				if ($i < $max_page) {
					$page .= '<a href="'.'../'.$dirurl.'/'.($i + 1).'.html" >Next Page</a>';
				} else {
					$page .= '<a >Next Page</a>';
				}
				$page .= '</div><div class="fr">Results '.$page_start.' - '.$page_end.'  of '.$total.'</div>
						 <div class="clear"></div>';
			}
			$page = '<div class="helist">'.$list.'</div>'.$page;//列表与分页div合并
			//预览
			if ($get['do'] == 'view') {
				return $page;
			}

			$temp = str_replace('<!--page_module-->', $page, $temp);
			$temp = str_replace('$'.'{具体Order分类列表和分页信息}', '', $temp);
			
			$temp = str_replace('$'.'{页面关键字}', $get['页面关键字'], $temp);
			$temp = str_replace('$'.'{所有一级分类}', $this->getAllOneCategory($get), $temp);
			$temp = str_replace('$'.'{页面描述}', $get['页面描述'], $temp);
			$temp = str_replace('$'.'{页面title}', $get['页面title'].' of '.$i, $temp);
			
			$temp = str_replace('$'.'{页面标题}', $get['页面标题'].' of '.$i, $temp);
			
			$temp = str_replace('$'.'{FAQ分类名称}', $get['FAQ分类名称'], $temp);
			
			$temp = str_replace('$'.'{具体Order分类列表}', $this->getDefiniteOrderCategoryList($get), $temp);
			$temp = str_replace('$'.'{OrderSupport首页链接}', $this->getOrderIndexHref($get), $temp);
			$temp = str_replace('$'.'{ProductsSupport首页链接}', $this->getProductsIndexHref($get), $temp);
		
			$temp = str_replace('$'.'{登录html}', $this->getLoginHtml($get), $temp);
			$temp = str_replace('$'.'{登录js}', $this->getLoginJs($get), $temp);
			$temp = str_replace('$'.'{头文件}', $this->headerFile($get), $temp);
			$temp = str_replace('$'.'{脚文件}', $this->footerFile($get), $temp);
			$str_link  = '';
			if ($max_page == 1) {
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			} else if($i == 1 ) {
				$str_link = '<link rel="next" href="'.'../'.$dirurl.'/'.($i + 1).'.html"/>';
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			} else if ($i > 1 && $i < $max_page) {
				
				$str_link = '<link rel="canonical" href="'.'../'.$dirurl.'/'.'"/>';
				if (($i - 1) == 1) {
					$str_link .= '<link rel="prev" href="'.'../'.$dirurl.'/"/>';
				} else {
					$str_link .= '<link rel="prev" href="'.'../'.$dirurl.'/'.($i - 1).'.html"/>';
				}
				
				$str_link .= '<link rel="next" href="'.'../'.$dirurl.'/'.($i + 1).'.html"/>';
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			} else if($i == $max_page) {
				$str_link = '<link rel="canonical" href="'.'../'.$dirurl.'/'.'"/>';
				if (($i-1) == 1) {
					$str_link .= '<link rel="prev" href="'.'../'.$dirurl.'/"/>';
				} else {
					$str_link .= '<link rel="prev" href="'.'../'.$dirurl.'/'.($i - 1).'.html"/>';
				}
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			}
			
			if ($i == 1) {
				file_put_contents($dir.'/index.html', $temp);
			
			} else
			{
				file_put_contents($dir.'/'.$i.'.html', $temp);
			}

		}
	}
	
	/**
	* 得到Products-Support-TroubleshootingFAQ   生成分页
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getHowTosCreatePage($get = array() ) {
		
		$arr = $this->howTosCreatePage($get);
		$webInfo = $arr['webInfo'];
		$total = $arr['total'];
		$max_page = $arr['max_page'];
		$dirurl = $arr['dirurl'];
		$dir = $arr['dir'];
		$template_str = $arr['template_str'];
		$all = $arr['all'];
		
		for ($i = 1; $i <= $max_page; $i++)  {
			
			$list = '';
			$temp = $template_str;
			$page_start = ($i - 1) * 10 + 1;
			$page_end = ($i - 1) * 10 + 10;
			
			if ($page_end >= $total) {
				$page_end = $total;
			}
			
			$chang_sum = 0;
			$k = 0;
			
			for ($j = ($i - 1) * 10; $j <= $i * 10 - 1; $j++)  {
				
				if ($j >= $total) {
					break;   
				}
				$url = url_new_replace($all[$j]['url'], $webInfo['url_type'], $webInfo['web_domain']);
				$list.='<div class="toggle-item" id='.$all[$j]['id'].'>';
				$chang_sum = $chang_sum + 1;
				$list.='<a href="#'.$all[$j]['id'].'" class="question" ><strong  id="title_'.$all[$j]['id'].'">'.$all[$j]['title'].'</strong></a><div class="answer"><p>
						'.support_replace_img($all[$j]['contents'], 'i.iskysoft.com').'</p>
						<div class="mtb10"><strong>Is this information helpful?</strong>
						<label><input name="helpful_'.$all[$j]['id'].'" type="radio" onclick="insert_comment('.$all[$j]['id'].',1,1)"/> Yes</label> 
						<label><input name="helpful_'.$all[$j]['id'].'" type="radio"  onclick="insert_comment('.$all[$j]['id'].',0,1)"/> No</label>
						</div></div></div>';
				$k = $k +1;
			}

			if($total > 10) {
				//分页
				$page = '<div id="page">';
				if ( $i  > 1 ) {
					if ($i -1 == 1)
					{
						$page .= '<a href="'.'../../'.$dirurl.'/" > Prev Page</a>';
					} else {
						$page .= '<a href="'.'../../'.$dirurl.'/'.($i - 1).'.html" >Prev Page</a>';
					}
				} else {
					$page .= '<a >< prev page</a>';
				}
				
				$start = $i - 4;
				$end = $i + 4;
				
				if ($start < 1) {
					$start = 1; $end = 6;
				}
					
				if ($end > $max_page) {
					$end = $max_page; $start = $max_page - 5;
				}
				
				if ($start < 1){
					$start = 1;
				}
				
				if ($start != 1){
					$output .= '';
				}
				
				for ($start; $start <= $end; $start++)
				{
					
					if ($i == $start) {
						$page .= '<a class="now_page" >'.$start.'</a>';
					} else {
						
						if($start == 1){
							$page .= '<a href="'.'../../'.$dirurl.'/">'.$start.'</a>';
						}else{
							$page .= '<a href="'.'../../'.$dirurl.'/'.$start.'.html">'.$start.'</a>';
						}
					}
				}
				
				if ($end != $max_page) {
					$output .= '';
				}
				
				if ($i < $max_page) {
					$page .= '<a href="'.'../../'.$dirurl.'/'.($i + 1).'.html" >Next Page</a>';
				}else {
					$page .= '<a >Next Page</a>';
				}
				
				$page .= '</div><div class="fr">Results '.$page_start.' - '.$page_end.'  of '.$total.'</div>
				<div class="clear"></div>';
			}
			$page = $list.'<br>'.$page;//列表与分页div合并
			
			//预览
			if ($get['do'] == 'view') {
				return $page;
			}

			$temp = str_replace('<!--page_module-->', $page, $temp);
			$temp = str_replace('$'.'{HowTos列表和分页信息}', '', $temp);
			
			$temp = str_replace('$'.'{页面关键字}', $get['页面关键字'], $temp);
			$temp = str_replace('$'.'{所有一级分类}', $this->getAllOneCategory($get), $temp);
			$temp = str_replace('$'.'{页面描述}', $get['页面描述'], $temp);
			
			$temp = str_replace('$'.'{OrderSupport首页链接}', $this->getOrderIndexHref($get), $temp);
			$temp = str_replace('$'.'{ProductsSupport首页链接}', $this->getProductsIndexHref($get), $temp);
			$temp = str_replace('$'.'{所有下载链接}', $this->getAllDownloadHref($get), $temp);
			$temp = str_replace('$'.'{页面title}', $get['页面title'].' of '.$i, $temp);
			$temp = str_replace('$'.'{Troubleshooting链接}', $this->getHowTosHref($get), $temp);
			$temp = str_replace('$'.'{GettingStarted链接}', $this->getGettingStartedHref($get), $temp);
			$temp = str_replace('$'.'{登录html}', $this->getLoginHtml($get), $temp);
			$temp = str_replace('$'.'{登录js}', $this->getLoginJs($get), $temp);
			$temp = str_replace('$'.'{头文件}', $this->headerFile($get), $temp);
			$temp = str_replace('$'.'{脚文件}', $this->footerFile($get), $temp);
			$str_link  = '';
			
			if ($max_page == 1) {
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			} else if($i == 1 ) {
				$str_link = '<link rel="next" href="'.'../../'.$dirurl.'/'.($i + 1).'.html"/>';
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			} else if($i >1 && $i < $max_page) {
				$str_link = '<link rel="canonical" href="'.'../../'.$dirurl.'/'.'"/>';

				if (($i-1) == 1) {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/"/>';
				} else {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/'.($i - 1).'.html"/>';
				}
				
				$str_link .= '<link rel="next" href="'.'../../'.$dirurl.'/'.($i + 1).'.html"/>';
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			} else if ($i == $max_page) {
				
				$str_link = '<link rel="canonical" href="'.'../../'.$dirurl.'/'.'"/>';
				if (($i - 1) == 1) {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/"/>';
				} else {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/'.($i - 1).'.html"/>';
				}
				$temp = str_replace('$'.'{link代码}',$str_link,$temp);
			}
			if ($i == 1) {
				file_put_contents($dir.'/index.html', $temp);
			}else
			{
				file_put_contents($dir.'/'.$i.'.html', $temp);
			}

		}
	}
	
	/**
	* 得到在线帮助 生成分页
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getOnHelpCreatePage($get = array() ) {
		
		$arr = $this->onHelpCreatePage($get);
		$webInfo = $arr['webInfo'];
		$total = $arr['total'];
		$max_page = $arr['max_page'];
		$dirurl = $arr['dirurl'];
		$dir = $arr['dir'];
		$template_str = $arr['template_str'];
		$all = $arr['all'];
		
		for ($i = 1; $i <= $max_page; $i++)  {
			
			$list = '';
			$temp = $template_str;
			$page_start=($i - 1) * 10 + 1;
			$page_end=($i - 1) * 10 + 10;
			
			if ($page_end >= $total){
				$page_end = $total;
			}
			
			$chang_sum = 0;
			$k = 0;
		
			for ($j = ($i - 1)* 10; $j <= $i * 10 - 1; $j++) {
				
				if ($j >= $total) {
					break;   
				}
				$url = url_new_replace($all[$j]['url'],$webInfo['url_type'],$webInfo['web_domain']);
				$chang_sum = $chang_sum + 1;
				$list .= '<div class="pro-item"><a href="'.      
				$url.'">'.$all[$j]['title'].'</a><p>'.$all[$j]['description'].'<p></div>';
				$k = $k + 1;
			}
			
			if ($total > 10) {
				//分页
				$page = '<div id="page">';
				if ( $i  > 1 ) {
					if ($i -1 == 1) {
						$page .= '<a href="'.'../../'.$dirurl.'/" >Prev Page</a>';
					} else {
						$page .= '<a href="'.'../../'.$dirurl.'/'.($i - 1).'.html" >Prev Page</a>';
					}
				} else {
					$page .= '<a>Prev Page</a>';
				}
				
				$start = $i - 4;
				$end = $i + 4;
				
				if ($start < 1) {
					$start = 1; $end = 6;
				}
				
				if ($end > $max_page) {
					$end = $max_page; $start = $max_page - 5;
				}
				
				if ($start < 1) {
					$start = 1;
				}
				
				if ($start != 1) {
					$output .= '';
				}
				
				for ($start; $start <= $end; $start++) {
					
					if ($i == $start) {
						$page .= '<a class="now_page" >'.$start.'</a>';
					} else {
					  if ($start == 1) {
					   $page .= '<a href="'.'../../'.$dirurl.'/">'.$start.'</a>';
					  } else {
					     $page .= '<a href="'.'../../'.$dirurl.'/'.$start.'.html">'.$start.'</a>';
					  }
					}
				}
				
				if ($end != $max_page) {
					$output .= '';
				}
				
				if ($i < $max_page) {
					$page .= '<a href="'.'../../'.$dirurl.'/'.($i+1).'.html" >Next Page</a>';
				} else {
					$page .= '<a >Next Page</a>';
				}
				
				$page .= '</div><div class="fr">Results '.$page_start.' - '.$page_end.'  of '.$total.'</div>
						<div class="clear"></div>';
			}
			
			$page = $list.$page;//列表与分页div合并
			//预览
			if ($get['do'] == 'view') {
				return $page;
			}
			
			$temp = str_replace('<!--page_module-->', $page, $temp);
			$temp = str_replace('$'.'{列表和分页信息在线帮助}', '', $temp);
			
			$temp = str_replace('$'.'{页面关键字}', $get['页面关键字'], $temp);
			$temp = str_replace('$'.'{所有一级分类}', $this->getAllOneCategory($get), $temp);
			$temp = str_replace('$'.'{页面描述}', $get['页面描述'], $temp);
	
			
			$temp = str_replace('$'.'{OrderSupport首页链接}', $this->getOrderIndexHref($get), $temp);
			$temp = str_replace('$'.'{ProductsSupport首页链接}', $this->getProductsIndexHref($get), $temp);
			$temp = str_replace('$'.'{所有下载链接}', $this->getAllDownloadHref($get), $temp);
			
			$temp = str_replace('$'.'{页面title}', $get['页面title'].' of '.$i, $temp);
			
			$temp = str_replace('$'.'{Troubleshooting链接}', $this->getHowTosHref($get), $temp);
			$temp = str_replace('$'.'{GettingStarted链接}', $this->getGettingStartedHref($get), $temp);
			$temp = str_replace('$'.'{登录html}', $this->getLoginHtml($get), $temp);
			$temp = str_replace('$'.'{登录js}', $this->getLoginJs($get), $temp);
			$temp = str_replace('$'.'{头文件}', $this->headerFile($get), $temp);
			$temp = str_replace('$'.'{脚文件}', $this->footerFile($get), $temp);
			$str_link  = '';
			
			if ($max_page == 1) {
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			} else if ($i == 1 ) {
			
				$str_link = '<link rel="next" href="'.'../../'.$dirurl.'/'.($i + 1).'.html"/>';
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			} else if ($i >1 && $i < $max_page) {
				$str_link = '<link rel="canonical" href="'.'../../'.$dirurl.'/'.'"/>';
				if (($i-1) == 1) {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/"/>';
				} else {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/'.($i - 1).'.html"/>';
				}
				$str_link .= '<link rel="next" href="'.'../../'.$dirurl.'/'.($i + 1).'.html"/>';
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			} else if ($i == $max_page) {
				$str_link = '<link rel="canonical" href="'.'../../'.$dirurl.'/'.'"/>';
				if (($i-1) == 1) {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/"/>';
				} else {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/'.($i - 1).'.html"/>';
				}
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			}
	
			if ($i == 1) {
				file_put_contents($dir.'/index.html', $temp);
			
			} else {
				file_put_contents($dir.'/'.$i.'.html', $temp);
			}
			
		}
		
	}
	
	/**
	* 得到在线帮助 生成分页
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getDownloadCreatePage($get = array() ) {
		
		$arr = $this->downloadCreatePage($get);
		$webInfo = $arr['webInfo'];
		$total = $arr['total'];
		$max_page = $arr['max_page'];
		$dirurl = $arr['dirurl'];
		$dir = $arr['dir'];
		$template_str = $arr['template_str'];
		$all = $arr['all'];
		
		for ($i = 1; $i <= $max_page; $i++) {
			
			$list = '';
			$temp = $template_str;
			$page_start=($i-1) * 10 + 1;
			$page_end=($i-1) * 10 + 10;
			if ($page_end >= $total) {
				$page_end = $total;
			}
			
			$chang_sum = 0;
			$k = 0;
			
			for ($j = ($i - 1)* 10; $j <= $i * 10 - 1; $j++) {
				
				if ($j >= $total) {
					break;   
				}
				
				$url = url_new_replace($all[$j]['url'], $webInfo['url_type'], $webInfo['web_domain']);
				$chang_sum = $chang_sum + 1;
				
				$list.='<div class="down-item">
						<span class="downArea"><a href="'.$all[$j]['download_url'].'">Download</a> (Version: '.$all[$j]['version_name'].')</span>
						<a href="'.$all[$j]['p_url'].'">'.$all[$j]['product_name'].'</a><p>'.$all[$j]['product_support_intro'].'</p> </div>';

				$k = $k +1;
			}
			
			if($total > 10) {
				//分页
				$page = '<div id="page">';
				if ( $i  > 1 ) {
					if ($i -1 == 1) {
						$page .= '<a href="'.'../../'.$dirurl.'/" >Prev Page</a>';
					} else {
						$page .= '<a href="'.'../../'.$dirurl.'/'.($i - 1).'.html">Prev Page</a>';
					}
				} else {
					$page .= '<a>Prev Page</a>';
				}
				
				$start = $i - 4;
				$end = $i + 4;
				
				if ($start < 1) {
					$start = 1; $end = 6;
				}
				
				if ($end > $max_page) {
					$end = $max_page; $start = $max_page - 5;
				}
				
				if ($start < 1) {
					$start = 1;
				}
				
				if ($start != 1) {
					$output .= '';
				}
				
				for ($start; $start <= $end; $start++) {
					
					if ($i == $start) {
						$page .= '<a class="now_page" >'.$start.'</a>';
					} else {
						if ($start == 1) {
							$page .= '<a href="'.'../../'.$dirurl.'/">'.$start.'</a>';
						} else {
							 $page .= '<a href="'.'../../'.$dirurl.'/'.$start.'.html">'.$start.'</a>';
						}
					}
				}
				
				if ($end != $max_page) {
					$output .= '';
				}
				
				if ($i < $max_page) {
					$page .= '<a href="'.'../../'.$dirurl.'/'.($i + 1).'.html" >Next Page</a>';
				} else {
					$page .= '<a >Next Page</a>';
				}
				
				$page .= '</div><div class="fr">Results '.$page_start.' - '.$page_end.'  of '.$total.'</div>
				<div class="clear"></div>';
			}
			
			$page = $list.'<br>'.$page;//列表与分页div合并
			//预览
			if ($get['do'] == 'view') {
				return $page;
			}
			$temp = str_replace('<!--page_module-->', $page, $temp);
			$temp = str_replace('$'.'{下载列表和分页信息}', '', $temp);
			
			$temp = str_replace('$'.'{页面关键字}', $get['页面关键字'], $temp);
			$temp = str_replace('$'.'{所有一级分类}', $this->getAllOneCategory($get), $temp);
			$temp = str_replace('$'.'{页面描述}', $get['页面描述'], $temp);

			
			$temp = str_replace('$'.'{OrderSupport首页链接}', $this->getOrderIndexHref($get), $temp);
			$temp = str_replace('$'.'{ProductsSupport首页链接}', $this->getProductsIndexHref($get), $temp);
			$temp = str_replace('$'.'{所有下载链接}', $this->getAllDownloadHref($get), $temp);
			
			$temp = str_replace('$'.'{页面title}', $get['页面title'].' of '.$i, $temp);
			
			$temp = str_replace('$'.'{Troubleshooting链接}', $this->getHowTosHref($get), $temp);
			$temp = str_replace('$'.'{GettingStarted链接}', $this->getGettingStartedHref($get), $temp);
			$temp = str_replace('$'.'{登录html}', $this->getLoginHtml($get), $temp);
			$temp = str_replace('$'.'{登录js}', $this->getLoginJs($get), $temp);
			$temp = str_replace('$'.'{头文件}', $this->headerFile($get), $temp);
			$temp = str_replace('$'.'{脚文件}', $this->footerFile($get), $temp);
			$str_link  = '';
			
			if ($max_page == 1) {
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			} else if ($i == 1 ) {
				$str_link = '<link rel="next" href="'.'../../'.$dirurl.'/'.($i + 1).'.html"/>';
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			} else if ($i >1 && $i < $max_page)
			{
				$str_link = '<link rel="canonical" href="'.'../../'.$dirurl.'/'.'"/>';
				if (($i - 1) == 1) {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/"/>';
				} else {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/'.($i - 1).'.html"/>';
				}
				$str_link .= '<link rel="next" href="'.'../../'.$dirurl.'/'.($i + 1).'.html"/>';
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			} else if ($i == $max_page) {
				$str_link = '<link rel="canonical" href="'.'../../'.$dirurl.'/'.'"/>';
				if (($i - 1) == 1) {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/"/>';
				} else {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/'.($i - 1).'.html"/>';
				}
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			}

			if ($i == 1) {
				file_put_contents($dir.'/index.html', $temp);
			
			} else {
				file_put_contents($dir.'/'.$i.'.html', $temp);
			}
		}
		
		return '';
		
	}
	
	/**
	* 得到产品HowTos 生成分页
	*
	* @param   array      		 $get       字段数组
	* @return  string
	*/
	function getProductHowTosCreatePage($get = array() ) {
	
		$arr = $this->productHowTosCreatePage($get);
		$webInfo = $arr['webInfo'];
		$total = $arr['total'];
		$max_page = $arr['max_page'];
		$dirurl = $arr['dirurl'];
		$dir = $arr['dir'];
		$template_str = $arr['template_str'];
		$all = $arr['all'];
		
		for ($i = 1; $i <= $max_page; $i++)  {
			
			$list = '';
			$temp = $template_str;
			$page_start = ($i - 1) * 10 + 1;
			$page_end = ($i - 1) * 10 + 10;
			
			if ($page_end >= $total) {
				$page_end = $total;
			}
			
			$chang_sum = 0;
			$k = 0;
			
			for ($j = ($i - 1)* 10; $j <= $i * 10 - 1; $j++) {
				
				if ($j >= $total) {
					break;   
				}
				
				$chang_sum = $chang_sum + 1;
				$url = url_new_replace($all[$j]['url'], $webInfo['url_type'], $webInfo['web_domain']);
				$list .= '<div class="toggle-item" id="'.$all[$j]['id'].'">';
				
				$list .= '<a href="#'.$all[$j]['id'].'" class="question" ><strong id="title_'.$all[$j]['id'].'">'.$all[$j]['title'].'</strong></a><div class="answer"><p>
						'.support_replace_img($all[$j]['contents'], 'i.iskysoft.com').'</p>
						<div class="mtb10"><strong>Is this information helpful?</strong>
						<label><input name="helpful_'.$all[$j]['id'].'" type="radio" onclick="insert_comment('.$all[$j]['id'].',1,1)"/> Yes</label> 
						<label><input name="helpful_'.$all[$j]['id'].'" type="radio"  onclick="insert_comment('.$all[$j]['id'].',0,1)"/> No</label>
						</div></div></div>';
				$k = $k + 1;
			}
			
			$page = '';
			if($total>10) {
				//分页
				$page = '<div id="page">';
				if ( $i  > 1 ) {
					if ($i -1 == 1) {
						$page .= '<a href="'.'../../'.$dirurl.'/" >Prev Page</a>';
					} else {
						$page .= '<a href="'.'../../'.$dirurl.'/'.($i - 1).'.html" >Prev Page</a>';
					}
				} else {
					$page .= '<a>Prev Page</a>';
				}
				
				$start = $i - 4;
				$end = $i + 4;
				
				if ($start < 1) {
					$start = 1; $end = 6;
				}
				
				if ($end > $max_page) {
					$end = $max_page; $start = $max_page - 5;
				}
				
				if ($start < 1) {
					$start = 1;
				}
				
				if ($start != 1) {
					$output .= '';
				}
				
				for ($start; $start <= $end; $start++) {
					
					if ($i == $start) {
						$page .= '<a class="now_page" >'.$start.'</a>';
					} else {
						if ($start == 1) {
							$page .= '<a href="'.'../../'.$dirurl.'/">'.$start.'</a>';
						} else {
							$page .= '<a href="'.'../../'.$dirurl.'/'.$start.'.html">'.$start.'</a>';
						}
					}
				}
				
				if ($end != $max_page) {
					$output .= '';
				}
				if ($i < $max_page) {
					$page .= '<a href="'.'../../'.$dirurl.'/'.($i+1).'.html" >Next Page</a>';
				} else {
					$page .= '<a >Next Page</a>';
				}
				
				$page .= '</div><div class="fr">Results '.$page_start.' - '.$page_end.'  of '.$total.'</div>
				<div class="clear"></div>';
			}
			
			$page = '<div class="helist">'.$list.'</div>'.$page;//列表与分页div合并
			//不等于预览
			if ($get['do'] == 'view') {
				return $page;
			}
			$temp = str_replace("<!--page_module-->", $page, $temp);
			$temp = str_replace('$'.'{页面关键字}', $get['页面关键字'], $temp);
			$temp = str_replace('$'.'{页面描述}', $get['页面描述'], $temp);
			
			$temp = str_replace('$'.'{产品HowTos列表和分页信息}', '', $temp);
			$temp = str_replace('$'.'{OrderSupport首页链接}', $this->getOrderIndexHref($get), $temp);
			$temp = str_replace('$'.'{ProductsSupport首页链接}', $this->getProductsIndexHref($get), $temp);
			$temp = str_replace('$'.'{产品history链接}', $this->getProductHistoryHref($get), $temp);	
			$temp = str_replace('$'.'{overview链接}', $this->getProductOverviewHref($get), $temp);	
			$temp = str_replace('$'.'{产品suggestion链接}', $this->getProductSuggestionHref($get), $temp);
			$temp = str_replace('$'.'{是否有在线帮助}', $this->getProductOnhelpHref($get), $temp);
			
			$temp = str_replace('$'.'{是否有Troubleshooting}', $this->getProductHowtosHref($get), $temp);

			$temp = str_replace('$'.'{产品ID}', $get['产品ID'], $temp);
			$temp = str_replace('$'.'{页面title}', $get['页面title'].' of '.$i, $temp);

			$temp = str_replace('$'.'{产品cbsid}', $get['产品cbsid'], $temp);
			$temp = str_replace('$'.'{产品名称}', $get['产品名称'], $temp);
			$temp = str_replace('$'.'{登录html}', $this->getLoginHtml($get), $temp);
			$temp = str_replace('$'.'{登录js}', $this->getLoginJs($get), $temp);
			$temp = str_replace('$'.'{头文件}', $this->headerFile($get), $temp);
			$temp = str_replace('$'.'{脚文件}', $this->footerFile($get), $temp);
		
			$str_link  = '';
			
			if ($max_page == 1) {
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			} else if($i == 1 ) {
			
				$str_link = '<link rel="next" href="'.'../../'.$dirurl.'/'.($i + 1).'.html"/>';
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			} else if($i > 1 && $i < $max_page) {
				
				$str_link = '<link rel="canonical" href="'.'../../'.$dirurl.'/'.'"/>';
				if (($i - 1) == 1) {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/"/>';
				} else {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/'.($i - 1).'.html"/>';
				}
				
				$str_link .= '<link rel="next" href="'.'../../'.$dirurl.'/'.($i + 1).'.html"/>';
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
				
			} else if($i == $max_page) {
				$str_link = '<link rel="canonical" href="'.'../../'.$dirurl.'/'.'"/>';
				if (($i - 1) == 1) {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/"/>';
				} else {
					$str_link .= '<link rel="prev" href="'.'../../'.$dirurl.'/'.($i - 1).'.html"/>';
				}
				$temp = str_replace('$'.'{link代码}', $str_link, $temp);
			}

			if ($i == 1) {
				file_put_contents($dir.'/index.html', $temp);
			
			} else {
				file_put_contents($dir.'/'.$i.'.html', $temp);
			}
			
		}
		
	}
	
	
	
	
}
?>